'''
产生随机数据
'''
import random
import json
import os

data = [[116.5205,40.0303]]  # 起始点
number = 10000  # 数据数量
step = 0.0001  # 数据跨度
# 写入的JSON数据
new_dict = {
    "transmission_line": [],
    "tower": [],
    "stroke": [
        {
            "thunder_distance": 80000,
            "lighting_time": "2018-08-11 11:00:45.3413"
        },
        {
            "thunder_distance": 70000,
            "lighting_time": "2018-11-15 07:34:43.1082"
        },
        {
            "thunder_distance": 55000,
            "lighting_time": "2018-10-01 18:07:12.1453"
        }
    ]
}

v = [[2.0,0.0],[1.0,-2.0],[0.0,-2.0],[1.5,0.5],[0.5,1.5],[2.0,0.5],[0.5,-1.0],[-0.8,-1.5],[-0.8,0],[-0.5,-1.5]]

for i in range(number):
    d = data[-1].copy()
    d[0] += step * (random.gauss(0.25,1) + v[int(i/1000)][0])
    d[1] += step * (random.gauss(0.25,1) + v[int(i/1000)][1])
    data.append(d)
    if i % 1000 == 0:
        new_dict["tower"].append([d[0],d[1]])
    
with open(os.path.join(os.path.split(os.path.realpath(__file__))[0], "data.json"), "w") as f:
    new_dict["transmission_line"] = data
    json.dump(new_dict, f)
    print("Over!")